import 'package:lx_widgets_library/extension/enum_ex.dart';

import 'package:lx_widgets_library/language/language_util.dart';

enum OrderProgressState {
  // 已提交
  submited(0),
  // 处理中
  inProgress(1),
  // 完成
  completed(2),
  // 关闭
  closed(3);

  // key
  final int rawValue;

  // 初始化
  const OrderProgressState(this.rawValue);

  // 通过 rawValue 获取枚举类型
  static OrderProgressState? getTypeByNum(int rawValue) =>
      OrderProgressState.values
          .firstWhereOrNull((activity) => activity.rawValue == rawValue);

  String get title {
    switch (this) {
      case OrderProgressState.submited:
        return AppLanguageUtil.to.titleSubmitedOrderState;
      case OrderProgressState.inProgress:
        return AppLanguageUtil.to.titleInProgressOrderState;
      case OrderProgressState.completed:
        return AppLanguageUtil.to.titleCompletedOrderState;
      case OrderProgressState.closed:
        return AppLanguageUtil.to.titleClosedOrderState;
    }
  }
}
